﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using HengTong.Model.Db;
using HengTong.Model.Db.Hr;
using Microsoft.EntityFrameworkCore;
using TiaoTaoHelper.Wtm.Models;
using WalkingTec.Mvvm.Core;

namespace HengTong.Model._Admin
{
    /// <summary>
    /// 用户
    /// </summary>
    [Table("FrameworkUsers")]
    [SoftKey(nameof(FrameworkUser.ITCode))]
    [Display(Name = "_Model.FrameworkUser")]
    public class FrameworkUser : FrameworkUserBase
    {
        [Display(Name = "_Model._FrameworkUser._Email")]
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("邮箱")]
        [RegularExpression("^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$",
            ErrorMessage = "Validate.{0}formaterror")]
        public string Email { get; set; }

        [Display(Name = "_Model._FrameworkUser._CellPhone")]
        [Comment("手机")]
        [RegularExpression("^[1][3456789][0-9]{9}$", ErrorMessage = "Validate.{0}formaterror")]
        [StringLength(32)]
        public string CellPhone { get; set; }

        [Display(Name = "是否允许访问公网")] public bool IsAccessInternet { get; set; }

        [Display(Name = "EasId")]
        [StringLength(128)]
        public string ErpId { get; set; }

        /// <summary>
        /// 默认部门 全部部门请查询 FrameworkUserGroup 表
        /// </summary>
        [Display(Name = "部门")]
        public SysGroup Group { get; set; }

        /// <summary>
        /// 默认部门
        /// </summary>
        [Display(Name = "部门ID")]
        public Guid? GroupId { get; set; }

        /// <summary>
        /// 关联的人员档案
        /// </summary>
        public Guid? PersonId { get; set; }

        /// <summary>
        /// 关联的人员档案
        /// </summary>
        public SysPerson Person { get; set; }
    }
}